<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../vue.js"></script>
</head>
<body>
<div id="app">
    <p>{{totalCount}}</p>
    <button-counter v-on:increment="incrementTotal"></button-counter>
    <button-counter v-on:increment="incrementTotal"></button-counter>
</div>

<script>
    Vue.component('button-counter', {
        template: '<button @click="inc">{{count}}</button>',
        data: function () {
            return {count : 0}
        },
        methods: {
            inc: function () {
                this.count++;
                this.$emit('increment');
            }
        }
    })



    new Vue({
        el: "#app",
        data: {
            totalCount: 0
        },
        methods: {
            incrementTotal: function () {
                this.totalCount++;
            }
        }
    })

</script>

</body>
</html>